import os
import platform
from unittest import TestCase

from lib.api.headspin import HeadSpinAPI
from util.logger import AutomationLogger


class BaseTest(TestCase):

    @property
    def project_path_root(self):
        return self.__project_root

    @property
    def test_path_root(self):
        return self.__test_path_root

    @property
    def test_data_path(self):
        return os.path.join(os.path.sep, self.__project_root, 'testdata')

    @property
    def test_method_name(self):
        return self._testMethodName

    @classmethod
    def setUpClass(cls):
        """Sets up things for the class"""

        super().setUpClass()
        library_path = os.path.abspath(__file__).split(os.path.sep)[0:-2]

        if platform.system().lower() == 'windows':
            library_path[0] = library_path[0] + os.path.sep
        cls.__test_dir_name = 'tests'
        cls.__project_root = os.path.join(os.path.sep, *library_path)
        cls.__test_path_root = os.path.join(os.path.sep, *library_path, cls.__test_dir_name)

    def setUp(self, config):
        self.log_client = AutomationLogger()
        self.log_client.setUp()
        self.logger = self.log_client.logger
        self.hs_api = HeadSpinAPI(config)
        self.appPackage = 'com.appsflyer.androidsampleapp'
        self.androidBuildCommit = 'androidSampleApp.apk'
        self.bundle = 'com.ookla.speedtest'
        self.iosBuildCommit = 'Speedtest.ipa'

